$.ajaxPrefilter(function(options) {
    const ERR = `你没有登录！`;
    const TIMEOUTERR = `获取数据超时`;
    //为私人接口添加请求头
    if (/\/my\//.test(options.url)) options.headers = {
            Authorization: sessionStorage.getItem(TOKEN)
        }
        //为接口添加基地址
    options.url = `${baseURL}${options.url}`;
    //为请求完成设定回调函数
    options.complete = function(res) {
        if (window.layui) layui.layer.closeAll(`loading`);
        if (res.statusText === `timeout`) {
            layer.msg(TIMEOUTERR);
        }
        if (res.status === 401 || res.responseJSON.message === `身份认证失败！`) {
            layer.alert(ERR, { closeBtn: 0 }, function() {
                window.top.location.href = `/login.html`;
                sessionStorage.removeItem(TOKEN);
            });
        }
    }
    if (window.layui) layui.layer.load();
})